package com.ebring.shareEducation.controller;

import com.ebring.shareEducation.service.UserTalentService;
import com.ebring.shareEducation.utils.RspMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class findPersonnalController {

    @Autowired
    private UserTalentService userTalentService;
 /*   @Autowired
    private CoinOrderService coinOrderService;*/

    @PostMapping("/findPersonnal/showContactInfo")
    public RspMsg showContactInfo(String userId,String talentId) {
        RspMsg rspMsg = new RspMsg();
       /* UserTalent userTalent = new UserTalent();
        userTalent.setUserTalentId("SEUT"+ UuidUtils.getNumberId(20));
        userTalent.setUserId(userId);
        userTalent.setTalentId(talentId);
        CoinOrder coinOrder = new CoinOrder();
        //扣除金币价格
        coinOrder.setAmount("1");
        coinOrder.setUserId(userId);
        coinOrder.setGetType("5");
        coinOrder.setTaskReleaseId(userTalent.getUserTalentId());
        RspMsg coinOrderRspMsg = coinOrderService.minusMoney(coinOrder);
        //金币扣除失败
        if(coinOrderRspMsg.getCode()==-1){
            rspMsg.setError();
            rspMsg.setMsg(coinOrderRspMsg.getMsg());
            return rspMsg;
        }
        int i = userTalentService.insertUserTalent(userTalent);
        if(i>0){
            rspMsg.setOK();
        }else{
            rspMsg.setError();
            rspMsg.setMsg("购买失败，请联系管理员！");
        }*/
        return null;
    }

    @PostMapping()
    public RspMsg findContactInfo(String userId,String talentId){
        RspMsg rspMsg =   new RspMsg();
        int i = userTalentService.selectUserTalent(userId, talentId);
        if(i<1){
            rspMsg.setError();
        }else{
            rspMsg.setOK();
        }
        return rspMsg;
    }

}
